﻿using Microsoft.Xna.Framework;
using CymbergajTouch.Logic;
using CymbergajTouch.Menu;

namespace CymbergajTouch.Components
{
    /// <summary>
    /// Options component that enables to change menu item's name.
    /// </summary>
    class OptionsComponent : MenuComponent
    {
        private Options options;
        private MenuItem soundItem;
        private MenuItem bonusesItem;
        private MenuItem goalsToWinItem;

        public OptionsComponent(Game game, KeyboardInput keyboardInput, Options options)
            : base(game, keyboardInput)
        {
            this.options = options;
            this.soundItem = new MenuItem(options.GetSoundOption(), options.ChangeSound);
            AddItem(soundItem);
            this.bonusesItem = new MenuItem(options.GetBonusesOption(), options.ChangeBonuses);
            AddItem(bonusesItem);
            this.goalsToWinItem = new MenuItem(options.GetGoalsToWinOption(), options.ChangeGoalsToWin);
            AddItem(goalsToWinItem);
            MenuItem doneItem = new MenuItem("Done", ((Cymbergaj)game).ShowMenu);
            AddItem(doneItem);
        }

        public override void Update(GameTime gameTime)
        {
            soundItem.Name = options.GetSoundOption();
            bonusesItem.Name = options.GetBonusesOption();
            goalsToWinItem.Name = options.GetGoalsToWinOption();
            base.Update(gameTime);
        }
    }
}
